/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.unibo.as.heartsprojectdb;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lilith
 */
@Entity
@Table(name = "gameusers")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Gameusers.findAll", query = "SELECT g FROM Gameusers g"),
    @NamedQuery(name = "Gameusers.findByUserFName", query = "SELECT g FROM Gameusers g WHERE g.userFName = :userFName"),
    @NamedQuery(name = "Gameusers.findByUserLName", query = "SELECT g FROM Gameusers g WHERE g.userLName = :userLName"),
    @NamedQuery(name = "Gameusers.findByUserEmail", query = "SELECT g FROM Gameusers g WHERE g.userEmail = :userEmail"),
    @NamedQuery(name = "Gameusers.findByUserNickname", query = "SELECT g FROM Gameusers g WHERE g.userNickname = :userNickname"),
    @NamedQuery(name = "Gameusers.findByUserPassword", query = "SELECT g FROM Gameusers g WHERE g.userPassword = :userPassword"),
    @NamedQuery(name = "Gameusers.findByUserLast", query = "SELECT g FROM Gameusers g WHERE g.userLast = :userLast")})
public class Gameusers implements Serializable {
    private static final long serialVersionUID = 1L;
    @Size(max = 45)
    @Column(name = "userFName")
    private String userFName;
    @Size(max = 45)
    @Column(name = "userLName")
    private String userLName;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "userEmail")
    private String userEmail;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "userNickname")
    private String userNickname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "userPassword")
    private String userPassword;
    @Size(max = 45)
    @Column(name = "userLast")
    private String userLast;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userEmail")
    private Collection<Gameplayer> gameplayerCollection;

    public Gameusers() {
    }

    public Gameusers(String userEmail) {
        this.userEmail = userEmail;
    }

    public Gameusers(String userEmail, String userNickname, String userPassword) {
        this.userEmail = userEmail;
        this.userNickname = userNickname;
        this.userPassword = userPassword;
    }

    public String getUserFName() {
        return userFName;
    }

    public void setUserFName(String userFName) {
        this.userFName = userFName;
    }

    public String getUserLName() {
        return userLName;
    }

    public void setUserLName(String userLName) {
        this.userLName = userLName;
    }

    public String getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public String getUserNickname() {
        return userNickname;
    }

    public void setUserNickname(String userNickname) {
        this.userNickname = userNickname;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public String getUserLast() {
        return userLast;
    }

    public void setUserLast(String userLast) {
        this.userLast = userLast;
    }

    @XmlTransient
    public Collection<Gameplayer> getGameplayerCollection() {
        return gameplayerCollection;
    }

    public void setGameplayerCollection(Collection<Gameplayer> gameplayerCollection) {
        this.gameplayerCollection = gameplayerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userEmail != null ? userEmail.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Gameusers)) {
            return false;
        }
        Gameusers other = (Gameusers) object;
        if ((this.userEmail == null && other.userEmail != null) || (this.userEmail != null && !this.userEmail.equals(other.userEmail))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.unibo.as.heartsprojectdb.Gameusers[ userEmail=" + userEmail + " ]";
    }
    
}
